//
//  IngredientsFoodController.m
//  Food
//
//  Created by dllo on 15/7/21.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "IngredientsFoodController.h"
#import "BaseHeader.h"
#import "IngredientsFondCollectionViewCell.h"
#import "myTap.h"
#import "AFNetworkHandler.h"
#import "IngredientsFoot.h"
#import "UIImageView+WebCache.h"
#import "GetHeight.h"
#import "HomePage_display_Controller.h"
#import "HomePage_detailed_model.h"
#import <MediaPlayer/MediaPlayer.h>
#import "MJRefresh.h"
@interface IngredientsFoodController () <UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout, UIScrollViewDelegate>

@property (nonatomic, retain) UIView *foodMovie;
@property (nonatomic, retain) UIView *controlView;
@property (nonatomic, retain) UICollectionView *collectionView;
@property (nonatomic, retain) UIImageView *make;
@property (nonatomic, retain) UIImageView *relate;
// 提示框
@property (nonatomic, retain) UIView *promptView;
// 提示框背景
@property (nonatomic, retain) UIView *promptBgView;
// 提示信息scroll
@property (nonatomic, retain) UIScrollView *scrollPrompt;
// 提示信息图片
@property (nonatomic, retain) UIImageView *imgPrompt;
// 提示信息文字
@property (nonatomic, retain) UILabel *lablePrompt;
// 相关常识view
@property (nonatomic, retain) UIView *relateView;
// 保存model 数组
@property (nonatomic, retain) NSMutableArray *arr;
// 保存提示框中数据
@property (nonatomic, retain) NSArray *promptArr;
// 提示框中提示信息自适应高度
@property (nonatomic, assign) CGFloat height;
// 制作菜例按钮上的图片
@property (nonatomic, retain) UIImageView *imgFood;
// 制作按钮上的文字
@property (nonatomic, retain) UILabel *lableFood;
// 相关按钮上的图片
@property (nonatomic, retain) UIImageView *imgRelate;
// 相关按钮上的文字
@property (nonatomic, retain) UILabel *lableRelate;
// 视频相关数据 图片: imagePath; 视屏: enjoyVideoName
@property (nonatomic, retain) NSArray *movieArr;
// 视频播放前显示的图片View
@property (nonatomic, retain) UIImageView *playerImg;
// 食材概述
@property (nonatomic, retain) UIImageView *overview;
// 营养功效
@property (nonatomic, retain) UIImageView *efficacy;
// 食用百科
@property (nonatomic, retain) UIImageView *wikipedia;
// 选购保存
@property (nonatomic, retain) UIImageView *chooseBay;
@property (nonatomic, retain) MPMoviePlayerController *player;
// 视频播放图片
@property (nonatomic, retain) UIImageView *imgButton;
@end

static NSInteger p = 1;

@implementation IngredientsFoodController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"naviBack"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(back)];
    
    [self createFoodMovie];
    [self createControlView];
    [self createCollectionView];
    [self createRelateView];
    [self performSelector:@selector(getDat) withObject:self afterDelay:1];
    [self refreshUp];
    [self getMovieData];
    [self createMoviewImg];
    
    
    
}

- (void) back
{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)viewWillAppear:(BOOL)animated
{
    self.tabBarController.tabBar.hidden = NO;
    self.navigationController.navigationBar.translucent = NO;
    p = 1;
}

- (void)viewWillDisappear:(BOOL)animated
{
    [self.player stop];
    [self.playerImg setHidden:NO];
}
#pragma mark - 获得数据

- (void) getDat
{
    
    UIActivityIndicatorView *activityIndicator = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge] autorelease];
    
    activityIndicator.frame = CGRectMake(0, 0, 100, 100);
    
    activityIndicator.color = [UIColor grayColor];
    
    activityIndicator.center = CGPointMake(ScreenWidth / 2.0, ScreenHeight / 2.0 - 50);
    
    [self.view addSubview:activityIndicator];
    
    [activityIndicator startAnimating];
    
    NSString *urlStr = [NSString stringWithFormat:@"http://121.41.88.179:80/HandheldKitchen/api/more/tblmmaterialtype!getVegetable.do?user_id=1&is_traditional=0&page=1&materialId=%@&phonetype=%ld&pageRecord=10", self.getID, p];
    [AFNetworkHandler getWithAFNByURL:urlStr completion:^(id result) {
        NSArray *tempArr = [result objectForKey:@"data"];
        NSArray *temp = [IngredientsFoot arrayWithModelByArray:tempArr];
        if (temp.count == 0) {
            self.collectionView.footerRefreshingText = @"数据加载完毕";
        } else {
            p++;
        }
        for (IngredientsFoot *model in temp) {
            [self.arr addObject:model];
        }
        [self.collectionView reloadData];
        [activityIndicator stopAnimating];
    }];
}

#pragma mark - 上拉加载
- (void) refreshUp
{
    self.arr = self.arr = [NSMutableArray array];
    NSLog(@"iiiii");
    [self.collectionView addFooterWithCallback:^{
        [self getDat];
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [self.collectionView footerEndRefreshing];
        });
    }];
    //
}

#pragma mark - 获取视频数据
- (void) getMovieData
{
    NSString *urlStr = [NSString stringWithFormat:@"http://121.41.84.91:80/HandheldKitchen/api/more/tblmmaterialtype!getMaterial.do?is_traditional=0&materialId=%@&phonetype=2", self.getID];
    [AFNetworkHandler getWithAFNByURL:urlStr completion:^(id result) {
        self.movieArr = [result objectForKey:@"data"];
        // 视频上的图片
        [self.playerImg sd_setImageWithURL:[NSURL URLWithString:[self.movieArr.lastObject objectForKey:@"imagePath"]]];
    }];
    
}

- (void) createMoviewImg
{
    self.playerImg = [[[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, (ScreenHeight - 64 - 49) / 3)] autorelease] autorelease];
    [self.view addSubview:self.playerImg];
    [self.playerImg setUserInteractionEnabled:YES];
    self.imgButton = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 64, 64)];
    self.imgButton.layer.cornerRadius = 32;
    self.imgButton.image = [UIImage imageNamed:@"player"];
    self.imgButton.center = CGPointMake(self.playerImg.center.x, self.playerImg.center.y);
    [self.imgButton setUserInteractionEnabled:YES];
    
    UITapGestureRecognizer *tap = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imgButtonTap)] autorelease];
    
    [self.imgButton addGestureRecognizer:tap];
    [self.playerImg addSubview:self.imgButton];
}

// 单击播放按钮
- (void) imgButtonTap
{
    //    [self.playerImg removeFromSuperview];
    [self.playerImg setHidden:YES];
    [self MoviePlayer];
    NSLog(@"asd");
}

// 视频
- (void) MoviePlayer
{
    NSLog(@"%@", self.movieArr);
    self.player = [[[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:[self.movieArr.lastObject objectForKey:@"enjoyVideoName"]]] autorelease];
    [self.player.view setFrame:self.foodMovie.bounds];
    //    self.player.shouldAutoplay = NO;
    self.player.controlStyle = MPMovieControlStyleDefault;
    // MPFullscreenOverlay
    [self.foodMovie addSubview:self.player.view];
    //    self.player.scalingMode = MPMovieScalingModeAspectFill;
    [self.player play];
}

- (void) createFoodMovie
{
    self.foodMovie = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, (ScreenHeight - 64 - 49) / 3)] autorelease];
    self.foodMovie.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"backGround"]];
    [self.view addSubview:self.foodMovie];
}

// 控制按钮
- (void) createControlView
{
    self.controlView = [[[UIView alloc] initWithFrame:CGRectMake(0, self.foodMovie.frame.size.height, ScreenWidth, 30)] autorelease];
    self.controlView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"backGround.jpg"]];
    self.make = [[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.controlView.frame.size.width / 3, self.controlView.frame.size.height)] autorelease];
    self.make.backgroundColor = [UIColor whiteColor];
    [self.make.layer setCornerRadius:15];
    [self.make setUserInteractionEnabled:YES];
    
    self.imgFood = [[[UIImageView alloc] initWithFrame:CGRectMake(10, 0, 30, 30)] autorelease];
    self.imgFood.image = [UIImage imageNamed:@"foo2"];
    self.lableFood = [[[UILabel alloc] initWithFrame:CGRectMake(30, 0, self.make.frame.size.width - 30, self.make.frame.size.height)] autorelease];
    self.lableFood.textColor = [UIColor blackColor];
    self.lableFood.text = @"制作菜例";
    self.lableFood.font = [UIFont systemFontOfSize:15];
    self.lableFood.textAlignment = NSTextAlignmentCenter;
    [self.make addSubview:self.imgFood];
    [self.make addSubview:self.lableFood];
    
    // 添加单击手势
    UITapGestureRecognizer *makeTap = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(makeTap)] autorelease];
    
    [self.make addGestureRecognizer:makeTap];
    
    [self.controlView addSubview:self.make];
    
    self.relate = [[[UIImageView alloc] initWithFrame:CGRectMake(self.controlView.frame.size.width - self.make.frame.size.width, 0, self.make.frame.size.width, self.controlView.frame.size.height)] autorelease];
    
    [self.relate setUserInteractionEnabled:YES];
    [self.relate.layer setCornerRadius:15];
    self.relate.backgroundColor = [UIColor whiteColor];
    
    self.imgRelate = [[[UIImageView alloc] initWithFrame:CGRectMake(10, 2.5, 25, 25)] autorelease];
    self.imgRelate.image = [UIImage imageNamed:@"relateOrange"];
    self.lableRelate = [[[UILabel alloc] initWithFrame:CGRectMake(30, 0, self.relate.frame.size.width - 30, 30)] autorelease];
    self.lableRelate.text = @"相关常识";
    self.lableRelate.textColor = [UIColor orangeColor];
    self.lableRelate.font = [UIFont systemFontOfSize:15];
    self.lableRelate.textAlignment = NSTextAlignmentCenter;
    [self.relate addSubview:self.imgRelate];
    [self.relate addSubview:self.lableRelate];
    // 添加手势
    UITapGestureRecognizer *relateTap = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(relateTap)] autorelease];
    [self.relate addGestureRecognizer:relateTap];
    
    [self.controlView addSubview:self.relate];
    
    // 黄线
    UIView *line = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, self.controlView.frame.size.width, 1)] autorelease];
    line.backgroundColor = [UIColor orangeColor];
    [self.controlView addSubview:line];
    
    [self.view addSubview:self.controlView];
}

#pragma mark - 实现controlView手势方法
- (void) makeTap
{
    
    
    for (UIView *v in self.view.subviews) {
        if (v.tag == 2001) {
            [self.relateView removeFromSuperview];
        }
    }
    self.imgFood.image = [UIImage imageNamed:@"foo2"];
    self.lableFood.textColor = [UIColor blackColor];
    self.imgRelate.image = [UIImage imageNamed:@"relateOrange"];
    self.lableRelate.textColor = [UIColor orangeColor];
    [self.view addSubview:self.collectionView];
    NSLog(@"sd");
}

- (void) relateTap
{
    for (UIView *v in self.view.subviews) {
        if (v.tag == 2000) {
            [self.collectionView removeFromSuperview];
        }
    }
    [self.view addSubview:self.relateView];
    self.imgFood.image = [UIImage imageNamed:@"food1"];
    self.lableFood.textColor = [UIColor orangeColor];
    self.imgRelate.image = [UIImage imageNamed:@"relateBlake"];
    self.lableRelate.textColor = [UIColor blackColor];
    NSLog(@"sp");
}

// 食品展示collectionView
- (void) createCollectionView
{
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    layout.itemSize = CGSizeMake((ScreenWidth - 20) / 2, (ScreenHeight - self.collectionView.frame.size.height - self.foodMovie.frame.size.height - 64) / 3);
    self.collectionView = [[[UICollectionView alloc] initWithFrame:CGRectMake(0, self.foodMovie.frame.size.height + self.controlView.frame.size.height, ScreenWidth, ScreenHeight - self.foodMovie.frame.size.height - self.controlView.frame.size.height - 64 - 49) collectionViewLayout:layout] autorelease];
    
    self.collectionView.tag = 2000;
    
    self.collectionView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
    
    self.collectionView.contentInset = UIEdgeInsetsMake(5, 5, 5, 5);
    
    self.collectionView.showsVerticalScrollIndicator = NO;
    
    self.collectionView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"backGround.jpg"]];
    
    self.collectionView.delegate = self;
    
    self.collectionView.dataSource = self;
    
    [self.collectionView registerClass:[IngredientsFondCollectionViewCell class] forCellWithReuseIdentifier:@"reuse"];
    
    [self.view addSubview:self.collectionView];
    
    
}

#pragma mark - 创建相关常识view
- (void) createRelateView
{
    self.relateView = [[[UIView alloc] initWithFrame:CGRectMake(0, self.foodMovie.frame.size.height + self.controlView.frame.size.height, ScreenWidth, ScreenHeight - self.foodMovie.frame.size.height - self.controlView.frame.size.height - 64 - 49)]autorelease];
    self.relateView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"backGround.jpg"]];
    self.relateView.tag = 2001;
    
    self.overview = [[[UIImageView alloc]initWithFrame:CGRectMake(10, 5, (ScreenWidth - 20 - 15) / 2, self.relateView.frame.size.height / 5 * 2)] autorelease];
    self.overview.image = [UIImage imageNamed:@"baike"];
    
    // overviewTitle
    UILabel *overViewLable = [[[UILabel alloc] initWithFrame:CGRectMake(0, self.overview.frame.size.height / 7 * 3.5, self.overview.frame.size.width, 40)] autorelease];
    overViewLable.text = @"食材概述";
    overViewLable.textAlignment = NSTextAlignmentCenter;
    overViewLable.font = [UIFont systemFontOfSize:20];
    //    overViewLable.backgroundColor = [UIColor redColor];
    [self.overview addSubview:overViewLable];
    [self.relateView addSubview:self.overview];
    
    // 添加手势
    myTap *overviewTap = [[myTap alloc] initWithTarget:self action:@selector(tap:)];
    overviewTap.tag = 5000;
    [self.overview setUserInteractionEnabled: YES];
    [self.overview addGestureRecognizer:overviewTap];
    
    self.efficacy = [[[UIImageView alloc]initWithFrame:CGRectMake(25 + self.overview.frame.size.width, 5, self.overview.frame.size.width, self.overview.frame.size.height)] autorelease];
    self.efficacy.image = [UIImage imageNamed:@"xuangou"];
    
    // efficacyTitle
    UILabel *efficacyLable = [[[UILabel alloc] initWithFrame:CGRectMake(0, self.efficacy.frame.size.height / 7 * 3.5, self.efficacy.frame.size.width, 40)] autorelease];
    efficacyLable.text = @"营养功效";
    efficacyLable.font = [UIFont systemFontOfSize:20];
    efficacyLable.textAlignment = NSTextAlignmentCenter;
    //    overViewLable.backgroundColor = [UIColor redColor];
    [self.efficacy addSubview:efficacyLable];
    
    // efficacyTap
    myTap *efficacyTap = [[myTap alloc] initWithTarget:self action:@selector(tap:)];
    efficacyTap.tag = 5001;
    [self.efficacy setUserInteractionEnabled: YES];
    
    [self.efficacy addGestureRecognizer:efficacyTap];
    [self.relateView addSubview:self.efficacy];
    
    self.chooseBay = [[[UIImageView alloc]initWithFrame:CGRectMake(10, self.overview.frame.size.height + 20, self.overview.frame.size.width, self.overview.frame.size.height)] autorelease];
    self.chooseBay.image = [UIImage imageNamed:@"gongxiao"];
    
    // chooseBayTitle
    UILabel *chooseBayLable = [[[UILabel alloc] initWithFrame:CGRectMake(0, self.chooseBay.frame.size.height / 7 * 3.5, self.chooseBay.frame.size.width, 40)] autorelease];
    chooseBayLable.text = @"选购保存";
    chooseBayLable.textAlignment = NSTextAlignmentCenter;
    chooseBayLable.font = [UIFont systemFontOfSize:20];
    //    overViewLable.backgroundColor = [UIColor redColor];
    [self.chooseBay addSubview:chooseBayLable];
    
    // chooseBayTap
    myTap *chooseBayTap = [[myTap alloc] initWithTarget:self action:@selector(tap:)];
    chooseBayTap.tag = 5002;
    [self.chooseBay setUserInteractionEnabled: YES];
    
    [self.chooseBay addGestureRecognizer:chooseBayTap];
    [self.relateView addSubview:self.efficacy];
    
    [self.relateView addSubview:self.chooseBay];
    
    self.wikipedia = [[[UIImageView alloc]initWithFrame:CGRectMake(self.efficacy.frame.origin.x, self.chooseBay.frame.origin.y, self.overview.frame.size.width, self.overview.frame.size.height)] autorelease];
    self.wikipedia.image = [UIImage imageNamed:@"shicai"];
    
    // wikipediaTitle
    UILabel *wikipediaLable = [[[UILabel alloc] initWithFrame:CGRectMake(0, self.wikipedia.frame.size.height / 7 * 3.5, self.wikipedia.frame.size.width, 40)] autorelease];
    wikipediaLable.text = @"食用百科";
    wikipediaLable.textAlignment = NSTextAlignmentCenter;
    wikipediaLable.font = [UIFont systemFontOfSize:20];
    //    overViewLable.backgroundColor = [UIColor redColor];
    [self.wikipedia addSubview:wikipediaLable];
    
    // wikepediaTap
    myTap *wikipediaTap = [[myTap alloc] initWithTarget:self action:@selector(tap:)];
    wikipediaTap.tag = 5003;
    [self.wikipedia setUserInteractionEnabled: YES];
    
    [self.wikipedia addGestureRecognizer:wikipediaTap];
    [self.relateView addSubview:self.efficacy];
    
    [self.relateView addSubview:self.wikipedia];
}
#pragma mark - 通过参数判断提示款大小, 显示内容.

#pragma mark - 提示框
- (void) createPromptView:(CGFloat) height
{
    self.promptBgView = [[[UIView alloc] initWithFrame:CGRectMake(0, -64, ScreenWidth, ScreenHeight)] autorelease];
    self.promptBgView.backgroundColor = [UIColor blackColor];
    self.promptBgView.alpha = 0.618;
    //    self.promptBgView.hidden = YES;
    
    [self.view addSubview:self.promptBgView];
    
    self.promptView = [[[UIView alloc] initWithFrame:CGRectMake(ScreenWidth / 2 - 120, ScreenHeight - 375 - 150 , 240, 375)] autorelease];
    self.promptView.center = CGPointMake(ScreenWidth / 2, ScreenHeight / 2 - 55);
    self.promptView.backgroundColor = [UIColor blackColor];
    //    self.promptView.hidden = YES;
    self.promptView.alpha = 0.8;
    [self.promptView.layer setCornerRadius:15];
    
    UIView *lineView = [[[UIView alloc] initWithFrame:CGRectMake(20, 20, 200, 1)] autorelease];
    lineView.backgroundColor = [UIColor grayColor];
    [self.promptView addSubview:lineView];
    
    // scrollPrompt
    self.scrollPrompt = [[[UIScrollView alloc] initWithFrame:CGRectMake(self.promptView.frame.origin.x + 20, self.promptView.frame.origin.y + 20, self.promptView.frame.size.width - 40, self.promptView.frame.size.height - 40)] autorelease];
    self.scrollPrompt.delegate = self;
    self.scrollPrompt.indicatorStyle = UIScrollViewIndicatorStyleWhite;
    self.scrollPrompt.backgroundColor = [UIColor clearColor];
    //    self.scrollPrompt.hidden = YES;
    
    self.imgPrompt = [[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.scrollPrompt.frame.size.width, self.scrollPrompt.frame.size.height / 3)] autorelease];
    self.imgPrompt.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"backGround.jpg"]];
    [self.scrollPrompt addSubview:self.imgPrompt];
    
    self.scrollPrompt.contentSize  = CGSizeMake(0, self.imgPrompt.frame.size.height + height + 10);
    
    // lablePrompt
    self.lablePrompt = [[UILabel alloc] initWithFrame:CGRectMake(0, self.imgPrompt.frame.size.height + 5, self.scrollPrompt.frame.size.width, height)];
    self.lablePrompt.backgroundColor = [UIColor clearColor];
    self.lablePrompt.numberOfLines = 0;
    self.lablePrompt.textColor = [UIColor whiteColor];
    [self.scrollPrompt addSubview:self.lablePrompt];
    // 关闭按钮
    UIImageView *shutImg = [[[UIImageView alloc] initWithFrame:CGRectMake(self.promptView.frame.size.width - 23, 2, 20, 20)] autorelease];
    shutImg.image = [UIImage imageNamed:@"guanbi"];
    [shutImg setUserInteractionEnabled:YES];
    // 添加手势
    UITapGestureRecognizer *shutImpTap = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(shutImpTap:)] autorelease];
    [shutImg addGestureRecognizer:shutImpTap];
    [self.promptView addSubview:shutImg];
    [self.view addSubview:self.promptView];
    [self.view addSubview:self.scrollPrompt];
    
}

- (void)getPromptData:(NSString *) strID type:(NSInteger) type
{
    NSString *urlStr = [NSString stringWithFormat:@"http://121.41.88.179:80/HandheldKitchen/api/more/tblmmaterialtype!getMaterialDetail.do?is_traditional=0&materialId=%@&materialType=%ld", strID, type];
    
    [AFNetworkHandler getWithAFNByURL:urlStr completion:^(id result) {
        self.promptArr = [result objectForKey:@"data"];
        CGFloat height = [GetHeight hight:[self.promptArr.lastObject objectForKey:@"schematic"]wide:200];
        [self createPromptView:height];
        [self.imgPrompt sd_setImageWithURL:[self.promptArr.lastObject objectForKey:@"storeFilename"]];
        self.lablePrompt.text = [self.promptArr.lastObject objectForKey:@"schematic"];
    }];
}

#pragma mark - 相关中的四个图片手势
- (void)tap:(myTap *)tag
{
    if (tag.tag == 5000) {
        NSLog(@"食材概述");
        [self getPromptData:self.getID type:1];
    }
    if (tag.tag == 5001) {
        [self getPromptData:self.getID type:2];
        NSLog(@"营养功效");
    }
    if (tag.tag == 5002) {
        [self getPromptData:self.getID type:3];
        NSLog(@"选购保存");
    }
    if (tag.tag == 5003) {
        [self getPromptData:self.getID type:4];
        NSLog(@"使用百科");
    }
    [self.overview setUserInteractionEnabled:NO];
    [self.chooseBay setUserInteractionEnabled:NO];
    [self.efficacy setUserInteractionEnabled:NO];
    [self.wikipedia setUserInteractionEnabled:NO];
//    [self.navigationItem setHidesBackButton:YES];
    self.navigationController.navigationBar.alpha = 0.618;
}

#pragma mark - shutImgTap
- (void) shutImpTap:(UITapGestureRecognizer *) tap
{
    NSLog(@"asdflkasd");
    self.promptBgView.hidden = YES;
    self.promptView.hidden = YES;
    self.scrollPrompt.hidden = YES;
    self.navigationController.navigationBar.alpha = 1;
    [self.overview setUserInteractionEnabled:YES];
    [self.chooseBay setUserInteractionEnabled:YES];
    [self.efficacy setUserInteractionEnabled:YES];
    [self.wikipedia setUserInteractionEnabled:YES];
}
#pragma mark - 返回cell个数
- (NSInteger) collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.arr.count;
}

#pragma mark - 返回自定义cell
- (UICollectionViewCell *) collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    IngredientsFondCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuse" forIndexPath:indexPath];
    cell.ingredientsFoot = self.arr[indexPath.item];
    return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    HomePage_display_Controller *display = [[HomePage_display_Controller alloc] init];
    IngredientsFoot *model = self.arr[indexPath.item];
    display.classid = model.vegetable_id;
    display.classTitle = model.name;
    display.MVBackGroundimage = model.imagePathThumbnails;
    [self.navigationController pushViewController:display animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
